import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      /* 设置那个模块需要自动导包 */
      imports: ['vue', 'vue-router'],
      /* plugins下的所有文件自动导包 */
      dirs: ['src/plugins/**', 'src/request/**', 'src/stores/**', 'src/Hooks/**'],
      /* 可以在这个文件下看哪些模块设置了自动导入 */
      dts: 'src/auto-imports.d.ts',
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
